package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.FollowList;
import com.myapp.ruyixing.model.FollowList.Follow;

public class FollowListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		FollowList followList = new FollowList();

		ListModelParser.parseListModel(followList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		followList.items = new ArrayList<FollowList.Follow>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				Follow follow = new Follow();
				follow.picurl = object.optString("picurl", "");
				follow.score = object.optString("score", "");
				follow.username = object.optString("username", "");
				follow.userid = object.optString("userid", "");
				followList.items.add(follow);
			}
		}

		return followList;

	}
}
